package com.jishuo.nontax.bfc.tlq;

import com.jishuo.base.util.StringObject;
import com.jishuo.base.util.StringUtil;
import com.jishuo.nontax.bean.bank.Bank;
import com.jishuo.nontax.bean.bank.PayWay;
import com.jishuo.nontax.bean.message.*;
import com.jishuo.nontax.bean.vo.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 财政交互，消息报文生成。
 *
 * @author jhb
 */
public class MessageFactory {

    // 获得电子票
    public static Object getEicketNum(String billNum) {
        GetEticketNumBills getEticketNumbills = new GetEticketNumBills();
        List<GetEticketNum> list = new ArrayList<>();
        GetEticketNum getEticketNum = new GetEticketNum();
        getEticketNum.setBillnum(billNum);
        list.add(getEticketNum);
        getEticketNumbills.setGetnum(list);
        return getEticketNumbills;
    }

    // 电子票缴费
    public static Object setEticketNumDeposit(List<EticketNumVO> voList) {
        SetEticketNumDepositBills setEticketNumDepositBills = new SetEticketNumDepositBills();
        List<SetEticketNumDeposit> list = new ArrayList<>();
        for (EticketNumVO eticketNum : voList) {
            //获取缴款书对象
            SetEticketNumDeposit seteticketNum = new SetEticketNumDeposit();
            seteticketNum.setAdmdivcode(eticketNum.getAdmdivcode());
            seteticketNum.setAgencycode(eticketNum.getAgencycode());
            seteticketNum.setAgencyname(eticketNum.getAgencyname());
            seteticketNum.setAmt(StringObject.objectString(eticketNum.getAmt()));
            seteticketNum.setBankaffirm(eticketNum.getBankaffirm());
            seteticketNum.setBankstation(eticketNum.getBankstation());
            seteticketNum.setBillnum(eticketNum.getBillnum());
            seteticketNum.setFilldate(eticketNum.getFilldate());
            seteticketNum.setPaybankdt(eticketNum.getPaybankdt());
            seteticketNum.setPayee(eticketNum.getPayee());
            seteticketNum.setPayeeaccount(eticketNum.getPayeeaccount());
            seteticketNum.setPayeebank(eticketNum.getPayeebank());
            seteticketNum.setPayer(eticketNum.getPayer());
            seteticketNum.setPayeraccount(eticketNum.getPayeraccount());
            seteticketNum.setPayerbank(eticketNum.getPayerbank());
            seteticketNum.setPaywayid(StringObject.objectString(eticketNum.getPayway()));
            seteticketNum.setVertifycode(eticketNum.getVertifycode());

            list.add(seteticketNum);
        }
        setEticketNumDepositBills.setSetnum(list);

        return setEticketNumDepositBills;
    }

    //获取化解专户
    public static Object getPaySpecial(String billnum) {
        GetPaySpecial getPaySpecial = new GetPaySpecial();
        getPaySpecial.setBillnum(billnum);
        return getPaySpecial;

    }

    //划解专户收款
    public static Object setSpecialPayInfo(PaySpecialVO paySpecial) {
        SetBankPaySpecial specail = new SetBankPaySpecial();
        specail.setPayid(StringObject.objectString(paySpecial.getPayid()));
        specail.setBillnum(paySpecial.getBillnum());
        specail.setCantonid(StringObject.objectString(paySpecial.getCantonid()));
        specail.setPayerbankid(StringObject.objectString(paySpecial.getPayerbankid()));
        specail.setPayeelevel(StringObject.objectString(paySpecial.getPayeelevel()));
        specail.setItemid(StringObject.objectString(paySpecial.getItemid1()));
        specail.setMoney(StringObject.objectString(paySpecial.getItemmoney1()));
        specail.setPayeeunitname(paySpecial.getPayeeunitname());
        specail.setPayeebankname(paySpecial.getPayeebankname());
        specail.setPayeeaccount(paySpecial.getPayeebankaccount());
        specail.setBankaffirm(StringObject.objectString(paySpecial.getBankaffirm()));
        specail.setPaybankdt(paySpecial.getPaybankdt());
        specail.setBankstation(StringObject.objectString(paySpecial.getBankstation()));
        return specail;
    }

    //获取交管二八分成单据
    public static Object getIllegalactivityScale(String billnum) {
        GetIllegalactivityScaleinfo scale = new GetIllegalactivityScaleinfo();
        scale.setBillnum(billnum);
        return scale;
    }

    //根据单据, 和单据编号查询 违章付款信息
    public static Object sendIllegalactivityScaleBankaffirm(PayScaleBillVO scaleBill) {
        SetBankIllegalactivityScaleinfo info = new SetBankIllegalactivityScaleinfo();
        ArrayList<SetBankIllegalactivityScaleinfoDetail> list = new ArrayList<>();
        SetBankIllegalactivityScaleinfoDetail detail = new SetBankIllegalactivityScaleinfoDetail();
        detail.setDetailno(StringObject.objectString(scaleBill.getBillno()));
        detail.setCollectcantonid(StringObject.objectString(scaleBill.getCollectcantonid()));
        detail.setCollectbankid(StringObject.objectString(scaleBill.getCollectbankid()));
        detail.setBankaffirm(scaleBill.getBankaffirm());
        detail.setCollectfund(StringObject.objectString(scaleBill.getFunds()));
        detail.setPaybankdt(scaleBill.getPaybankdt());
        detail.setBankstation(scaleBill.getBankstation());
        list.add(detail);
        info.setBankid(StringObject.objectString(scaleBill.getBankid()));
        info.setDetail(list);
        return info;

    }

    //获取划解国库单据
    public static Object getPayFisc(String billnum) {
        GetPayFisc fisc = new GetPayFisc();
        fisc.setBillnum(billnum);
        return fisc;
    }

    //划解国库缴费信息
    public static Object setFiscPayInfo(PayFiscVO payFiscVO) {
        SetBankPayFisc fisc = new SetBankPayFisc();
        fisc.setPayid(StringObject.objectString(payFiscVO.getPayid()));
        fisc.setBillnum(payFiscVO.getBillnum());
        fisc.setCantonid(StringObject.objectString(payFiscVO.getCantonid()));
        fisc.setPayerbankid(StringObject.objectString(payFiscVO.getPayerbankid()));
        fisc.setPayeedepart(payFiscVO.getPayeedepart());
        fisc.setPayeefisc(payFiscVO.getPayeefisc());
        fisc.setItemid(StringObject.objectString(payFiscVO.getItemid1()));
        fisc.setMoney(StringObject.objectString(payFiscVO.getItemmoney1()));
        fisc.setBankaffirm(payFiscVO.getBankaffirm());
        fisc.setPaybankdt(payFiscVO.getPaybankdt());
        fisc.setBankstation(payFiscVO.getBankstation());
        return fisc;
    }

    /**
     * @author hlp
     * @date 2023/2/6 16:31
     * @Description: 退付书缴费
     */
    public static Object setBackBillDeposit(BackpaybillVO backpaybillVO) {
        SetBackBillDeposit deposit = new SetBackBillDeposit();
        deposit.setBackbillnum(backpaybillVO.getBackbillnum());
        deposit.setBankaffirm(backpaybillVO.getBankaffirm());
        deposit.setBankstation(backpaybillVO.getBankstation());
        deposit.setDealdate(backpaybillVO.getDealdate());
        deposit.setKeyword(StringUtil.toStr(backpaybillVO.getKeyword()));
        deposit.setBankid(backpaybillVO.getBankid().toString());
        deposit.setCantonid(StringUtil.toStr(backpaybillVO.getCantonid()));
        deposit.setDrawaccount(backpaybillVO.getDrawaccount());
        deposit.setDrawbank(backpaybillVO.getDrawbank());
        deposit.setDrawman(backpaybillVO.getDrawman());
        deposit.setFund(backpaybillVO.getFund().toPlainString());
        deposit.setItemid(StringUtil.toStr(backpaybillVO.getItemid()));
        deposit.setUnitid(StringUtil.toStr(backpaybillVO.getUnitid()));
        return deposit;
    }

    //获取划解分成单据
    public static Object getPayDivide(String dividebillnum) {
        GetPayDivide payDivide = new GetPayDivide();
        payDivide.setDividebillnum(dividebillnum);
        return payDivide;
    }

    //划解分成缴费信息
    public static Object setDividePayInfo(PayDivideVO payDivide) {
        SetBankPayDivide divide = new SetBankPayDivide();
        divide.setPayid(StringObject.objectString(payDivide.getPayid()));
        divide.setDividebillnum(payDivide.getDividebillnum());
        divide.setCantonid(StringObject.objectString(payDivide.getCantonid()));
        divide.setUnitid(StringObject.objectString(payDivide.getUnitid()));
        divide.setParentunitid(StringObject.objectString(payDivide.getParentunitid()));
        divide.setItemid(StringObject.objectString(payDivide.getItemid()));
        divide.setMoney(StringObject.objectString(payDivide.getItemmoney()));
        divide.setParentunitid(StringObject.objectString(payDivide.getParentunitid()));
        divide.setPayerbankid(StringObject.objectString(payDivide.getPayerbankid()));
        divide.setBankaffirm(payDivide.getBankaffirm());
        divide.setPaybankdt(payDivide.getPaybankdt());
        divide.setBankstation(payDivide.getBankstation());
        return divide;
    }

    //获取交罚单据
    public static Object getIllegalactivityInfo(String billnum) {
        GetIllegalactivityinfo info = new GetIllegalactivityinfo();
        info.setBillnum(billnum);
        info.setPunishtype("301");
        return info;
    }

    //交罚缴费信息
    public static Object setPayInfo(IllegalactivityinfoVO infoVO) {
        SetPayinfo setPayinfo = new SetPayinfo();
        setPayinfo.setBankid(StringObject.objectString(infoVO.getBankid()));
        setPayinfo.setBillnum(infoVO.getBillnum());
        setPayinfo.setOccurname(infoVO.getOccurname());
        setPayinfo.setFunds(StringObject.objectString(infoVO.getFunds()));
        setPayinfo.setLatefee(infoVO.getLatefee().toPlainString());
        setPayinfo.setIsnohere(StringObject.objectString(infoVO.getIsnohere()));
        setPayinfo.setIsspecialbill(StringObject.objectString(infoVO.getIsspecialbill()));
        setPayinfo.setSpecialbillnum(infoVO.getSpecialbillnum());
        setPayinfo.setPaybankdt(infoVO.getPaybankdt());
        setPayinfo.setBankaffirm(infoVO.getBankaffirm());
        setPayinfo.setBankstation(infoVO.getBankstation());
        setPayinfo.setPaywayid(StringObject.objectString(infoVO.getPayway()));
        return setPayinfo;

    }

    //交管处罚跨省单据
    public static Object setIllegalactivityCrossPayInfo(IllegalactivityinfoVO vo) {

        SetIllegalactivityCrossPayInfo payinfo = new SetIllegalactivityCrossPayInfo();
        payinfo.setBillnum(vo.getBillnum());
        payinfo.setOccurdatetime(vo.getOccurdatetime());
        payinfo.setOpterdatetime(vo.getOpterdatetime());
        payinfo.setCertificatenum(vo.getCertificatenum());
        payinfo.setOccurname(vo.getOccurname());
        payinfo.setPayeeaccountnum(vo.getPayeeaccountnum());
        payinfo.setTrafficunitnum(vo.getTrafficunitnum());
        payinfo.setFunds(StringObject.objectString(vo.getFunds()));
        payinfo.setLatefee(vo.getLatefee().toPlainString());
        payinfo.setBankid(StringObject.objectString(vo.getBankid()));
        payinfo.setPayregion(vo.getPayregion());
        payinfo.setBreakaddress(vo.getBreakaddress());
        payinfo.setPaychannels(vo.getPaychannels());
        payinfo.setRemark(vo.getRemark());
        payinfo.setPaybankdt(vo.getPaybankdt());
        payinfo.setBankstation(vo.getBankstation());
        payinfo.setBankaffirm(vo.getBankaffirm());
        return payinfo;
    }

    //  修改罚没票据
    public static Object setPunishBillnum(IllegalactivityinfoVO vo) {

        SetPunishBillNum num = new SetPunishBillNum();
        num.setBillnum(vo.getBillnum());
        num.setBilltypeid(StringObject.objectString(vo.getBilltypeid()));
        num.setSpecialbillnum(vo.getSpecialbillnum());
        return num;
    }

    //滞纳金
    public static Object getLatefee(PunishInfoVO vo) {

        GetLatefee latefee = new GetLatefee();
        latefee.setPunishbillnum(vo.getPunishbillnum());
        latefee.setPaybankdt(vo.getPaybankdt());
        latefee.setUnitid(StringObject.objectString(vo.getUnitid()));
        latefee.setBillyear(vo.getBillyear());
        latefee.setIsremission(StringObject.objectString(vo.getIsremission()));
        latefee.setPunishdate(vo.getPunishdate());
        latefee.setPunishamt(StringObject.objectString(vo.getPunishamt()));
        return latefee;
    }

    // 银行代录罚没信息
    public static Object setPunishInfo(PunishInfoVO vo) {
        SetPunishinfo info = new SetPunishinfo();
        info.setPunishbillnum(vo.getPunishbillnum());
        info.setCantonid(StringObject.objectString(vo.getCantonid()));
        info.setUnitid(StringObject.objectString(vo.getUnitid()));
        info.setBillyear(vo.getBillyear());
        info.setPolicyfiles(vo.getPolicyfiles());
        info.setPolicynumber(vo.getPolicynumber());
        info.setSuborg(vo.getSuborg());
        info.setChildorg(vo.getChildorg());
        info.setPenaltyobjects(vo.getPenaltyobjects());
        info.setAddress(vo.getAddress());
        info.setIllegal(vo.getIllegal());
        info.setRegulations(vo.getRegulations());
        info.setPunishdecision(vo.getPunishdecision());
        info.setPunishbasis(vo.getPunishbasis());
        info.setPunishamt(StringObject.objectString(vo.getPunishamt()));
        info.setLatefee(vo.getLatefee().toPlainString());
        info.setPunishdate(vo.getPunishdate());
        info.setRecorddate(vo.getRecorddate());
        info.setIsremission(StringObject.objectString(vo.getIsremission()));
        info.setBankid(StringObject.objectString(vo.getBankid()));
        PunishDetailInfoVO infoVO = new PunishDetailInfoVO();
        SetPunishinfoDetail detail = infoVO.getPunishinfoDetail();
        ArrayList<SetPunishinfoDetail> list = new ArrayList<>();
        list.add(detail);
        info.setDetail(list);
        return info;
    }

    // 获得学生票
    public static Object getStudent(String studentnum) {
        GetStudent getStudent = new GetStudent();
        getStudent.setStudentnum(studentnum);
        return getStudent;
    }

    // 学生缴费信息
    public static Object setStudentPayInfo(StudentVO vo) {
        SetStudentPayinfo info = new SetStudentPayinfo();
        info.setStudentid(StringObject.objectString(vo.getStudentid()));
        info.setCantonid(StringObject.objectString(vo.getCantonid()));
        info.setUnitid(StringObject.objectString(vo.getUnitid()));
        info.setStudentnum(vo.getStudentnum());
        info.setClassname(vo.getClassname());
        info.setStudentname(vo.getStudentname());
        info.setBankid(StringObject.objectString(vo.getBankid()));
        info.setFund(StringObject.objectString(vo.getFunds()));
        info.setPayeraccount(vo.getPayeraccount());
        info.setPaybankdt(vo.getPaybankdt());
        info.setBankaffirm(vo.getBankaffirm());
        info.setBankstation(vo.getBankstation());
        return info;

    }

    //学生批扣信息
    public static Object setDeduct(List<DeductVO> deducts) {
        SetDeduct deduct = new SetDeduct();
        ArrayList<SetDeductDTO> list = new ArrayList<>();
        for (DeductVO vo : deducts) {
            SetDeductDTO dto = new SetDeductDTO();
            dto.setCantonid(StringObject.objectString(vo.getCantonid()));
            dto.setUnitid(StringObject.objectString(vo.getUnitid()));
            dto.setBankaffirm(vo.getBankaffirm());
            dto.setBankstation(vo.getBankstation());
            dto.setAccountcode(vo.getAccountcode());
            dto.setAccountdate(vo.getAccountdate());
            dto.setAccountname(vo.getAccountname());
            dto.setAccounttime(vo.getAccounttime());
            dto.setPayer(vo.getPayer());
            dto.setPayeraccountcode(vo.getPayeraccountcode());
            dto.setPayeraccountname(vo.getPayeraccountname());
            dto.setPayertypeid(StringObject.objectString(vo.getPayertypeid()));
            dto.setFund(StringObject.objectString(vo.getFund()));
            dto.setPostscript(vo.getPostscript());
            list.add(dto);
        }
        deduct.setDeduct(list);
        return deduct;
    }

    //账户余额
    public static Object getBankBalance(List<BankBalanceVO> bankBalanceVo) {
        SetBankBalance bankbalance = new SetBankBalance();
        ArrayList<SetBankBalanceDTO> setBankBalanceDTOS = new ArrayList<>();
        for (BankBalanceVO bankBalanceVO : bankBalanceVo) {
            setBankBalanceDTOS.add(bankBalanceVO.getSetBankBalanceDTO());
        }
        bankbalance.setBankbalance(setBankBalanceDTOS);
        return bankbalance;
    }

    // 对账
    public static Object getSetBankBillCheck(List<BankCheckBillVO> bankBalanceVo) {
        SetBankBillCheck bankcheck = new SetBankBillCheck();
        ArrayList<SetBankBillCheckDTO> setBankBalanceDTOS = new ArrayList<>();
        for (BankCheckBillVO bankBalanceVO : bankBalanceVo) {
            setBankBalanceDTOS.add(bankBalanceVO.getSetBankBillCheckDTO());
        }
        bankcheck.setBankcheck(setBankBalanceDTOS);
        return bankcheck;
    }

    //pos
    public static Object getSetBankPosDetail(ArrayList<BankPosVO> bankBalanceVo) {
        SetBankPosDetail bankcheck = new SetBankPosDetail();
        ArrayList<SetBankPosDetailDTO> setBankBalanceDTOS = new ArrayList<>();
        for (BankPosVO bankPosVO : bankBalanceVo) {
            setBankBalanceDTOS.add(bankPosVO.getSetBankPosDetailDTO());
        }
        bankcheck.setBankpos(setBankBalanceDTOS);
        return bankcheck;
    }


    //pos
    public static Object getSetBankPosNewDetail(ArrayList<BankPosNewVO> bankBalanceVo) {
        SetBankPosNewDetail bankcheck = new SetBankPosNewDetail();
        ArrayList<SetBankPosNewDetailDTO> setBankBalanceDTOS = new ArrayList<>();
        for (BankPosNewVO bankPosVO : bankBalanceVo) {
            setBankBalanceDTOS.add(bankPosVO.getSetBankPosNewDetailDTO());
        }
        bankcheck.setBankpos(setBankBalanceDTOS);
        return bankcheck;
    }

    public static Object getNewItemDTO(String itemcode) {
        NewItemDTO item = new NewItemDTO();
        item.setItemid("");
        item.setIslimit("");
        item.setItemcode(itemcode);
        item.setItemname("");
        item.setLowerlimit("");
        item.setMeasureunit("");
        item.setUpperlimit("");
        item.setOperate("-1");
        return item;
    }

    public static Object getGetBaseUnit(String cantonid, String unitcode) {
        GetBaseUnit unit = new GetBaseUnit();
        unit.setUnitid(0);
        unit.setCantonid(Integer.parseInt(cantonid));
        unit.setUnitcode(unitcode);
        unit.setUnitname("");
        unit.setOperate("-1");
        return unit;
    }

    public static Object getSetBankIllegalactivityScaleinfo(ArrayList<PayScaleBillVO> vos) {
        SetBankIllegalactivityScaleinfo bean = new SetBankIllegalactivityScaleinfo();

        ArrayList<SetBankIllegalactivityScaleinfoDetail> details = new ArrayList<>();
        for (PayScaleBillVO vo : vos) {
            SetBankIllegalactivityScaleinfoDetail details1 = vo.getDetails();
            bean.setBankid(vo.getBankid().toString());
            bean.setBillnum(vo.getBillnum());
            details.add(details1);

        }

        bean.setDetail(details);
        return bean;
    }

    public static Object getSetDivideBackOut(PayDivideVO vo) {

        SetBankPayDivideBackOut out = new SetBankPayDivideBackOut();
        out.setPayid(StringObject.objectString(vo.getPayid()));
        out.setDividebillnum(vo.getDividebillnum());
        out.setCantonid(StringObject.objectString(vo.getCantonid()));
        out.setUnitid(StringObject.objectString(vo.getUnitid()));
        out.setParentunitid(StringObject.objectString(vo.getParentunitid()));
        out.setItemid(StringObject.objectString(vo.getItemid()));
        out.setMoney(StringObject.objectString(vo.getItemmoney()));
        out.setPayerbankid(StringObject.objectString(vo.getPayerbankid()));
        out.setPayeebankid(StringObject.objectString(vo.getPayeebankid()));
        out.setBankaffirm(vo.getBankaffirm());
        out.setPaybankdt(vo.getPaybankdt());
        out.setBankstation(vo.getBankstation());
        return out;
    }

    public static Object getSetDeductBackOut(DeductVO vos) {
        SetDeductBackOut outs = new SetDeductBackOut();
        outs.setAccountcode(vos.getAccountcode());
        outs.setAccountdate(vos.getAccountdate());
        outs.setBankaffirm(vos.getBankaffirm());
       return outs;
    }

    public static Object getSetPunishinfoOut(PunishInfoVO vos) {
        SetPunishinfoOut  outs = new SetPunishinfoOut();
        outs.setBillyear(vos.getBillyear());
        outs.setPunishbillnum(vos.getPunishbillnum());
        outs.setUnitid(StringObject.objectString(vos.getUnitid()));
        return  outs;
    }

    public static Object getBaseUnit(int cantonid,String unitcode) {
        GetBaseUnit unit= new GetBaseUnit();
        unit.setUnitid(0);
        unit.setCantonid(cantonid);
        unit.setUnitcode(unitcode);
        unit.setUnitname("");
        unit.setOperate("-1");
        return unit;
    }

    public static Object getSetBankStationDTO(ArrayList<BankStationVO> list) {
        SetBankStation bankstation = new SetBankStation();
        ArrayList<SetBankStationDTO> setBankStationDTOS = new ArrayList<>();
        for (BankStationVO bankStationVO : list) {
            SetBankStationDTO setBankStationDTO = bankStationVO.getSetBankStationDTO();
            setBankStationDTOS.add(setBankStationDTO);
        }
        bankstation.setBankstation(setBankStationDTOS);
        return bankstation;
    }

    public static ArrayList<PayWay> getPayWay(ArrayList<PayWayVO> list) {
        ArrayList<PayWay> objects = new ArrayList<>();
        for (PayWayVO payWayVO : list) {
            PayWay payWay = payWayVO.getPayWay();
            objects.add(payWay);
        }
        return objects;
    }
    public static Object getDailiBankDTO(Long cantonid,String accountcode, String bankcls) {
        SetBankDTO dto = new SetBankDTO();
        dto.setBankname("");
        dto.setBankcls(bankcls);
        dto.setState("-1");
        dto.setAccountcode(accountcode);
        dto.setAccountname("");
        dto.setBankcode("");
        dto.setBankid("");
        dto.setBanklinenum("");
        dto.setCantonid(StringUtil.toStr(cantonid));
        return dto;
    }
    public static Bank getBank(Long cantonid,String accountcode) {
        Bank bank = new Bank();
        bank.setAccountcode(accountcode);
        bank.setBankid("");
        bank.setCantonid(StringObject.objectString(cantonid));
        bank.setBankcode("");
        bank.setBankname("");
        bank.setAccountname("");
        bank.setOperate("-1");
        return bank;
    }
    //99支出
    public static Object setWaitaffirmPayInfoDTO(WaitaffirmPayInfoVO vo){

        SetWaitaffirmPayInfoDTO bean = new SetWaitaffirmPayInfoDTO();
        bean.setBankaffirm(vo.getBankaffirm());
        bean.setBankid(StringObject.objectString(vo.getBankid()));
        bean.setCantonid(StringObject.objectString(vo.getCantonid()));
        bean.setItemid(StringObject.objectString(vo.getItemid()));
        bean.setOriginfund(StringObject.objectString(vo.getOriginfund()));
        bean.setPaybankdt(vo.getPaybankdt());
        bean.setPayeeaccountname(vo.getPayeeaccountname());
        bean.setPayeeaccountnum(vo.getPayeeaccountnum());
        bean.setPostscript(vo.getPostscript());
        bean.setUnitid(StringObject.objectString(vo.getUnitid()));
        return bean;
    }
}
